home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / Bird.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  3.1 KB  |  104 lines

  1. class Bird extends SideScroller.StaticObject
  2. {
  3.    var bObjectBlock;
  4.    var bObjectSpecial;
  5.    var nBaseY;
  6.    var mcRef;
  7.    var nSinGenerator;
  8.    var bDoEntrySound;
  9.    static var nMIN_X = 150;
  10.    static var nMOVE_SPEED = 3;
  11.    static var nSIN_INCREMENT = 0.15;
  12.    static var nSIN_MOD_MULT = 15;
  13.    static var nPROB_ENTRY_SOUND = 65;
  14.    static var nENTRY_SOUND_PLAYER_DIST = 350;
  15.    function Bird(__mcRef, __oLayer)
  16.    {
  17.       super(__mcRef,__oLayer);
  18.       this.bObjectBlock = false;
  19.       this.bObjectSpecial = true;
  20.       this.nBaseY = this.mcRef._y;
  21.       this.nSinGenerator = 0;
  22.       LevelManager.Instance.doPutInFront(this.mcRef);
  23.       this.setState("Idle");
  24.       if(Library.Utils.MoreMath.getRandomRange(1,100) < Bird.nPROB_ENTRY_SOUND)
  25.       {
  26.          this.bDoEntrySound = true;
  27.       }
  28.       else
  29.       {
  30.          this.bDoEntrySound = false;
  31.       }
  32.       this.ParentLayer.doAddListener(this);
  33.    }
  34.    function doPause()
  35.    {
  36.       super.doPause();
  37.       for(var _loc3_ in this.mcRef.mcState)
  38.       {
  39.          this.mcRef.mcState[_loc3_].stop();
  40.       }
  41.    }
  42.    function onHitSpecial(__oRef)
  43.    {
  44.       if(this.CurrentState == "Idle")
  45.       {
  46.          if(!TakGround(__oRef).IsInHeadSwing)
  47.          {
  48.             TakGround(__oRef).doReactCollision();
  49.          }
  50.          else
  51.          {
  52.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3",100,1,true);
  53.          }
  54.          var _loc2_ = this.ParentLayer.doAttachVisual("Tak_MiniM01");
  55.          _loc2_._x = this.Coord.x;
  56.          _loc2_._y = this.Coord.y;
  57.          LevelManager.Instance.doAddMiniStone(_loc2_);
  58.          Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdColision.mp3",100,1,true);
  59.          this.setState("Die");
  60.          this.doLockState();
  61.       }
  62.    }
  63.    function doDestroy()
  64.    {
  65.       this.ParentLayer.doRemoveListener(this);
  66.       super.doDestroy();
  67.    }
  68.    function doIdle()
  69.    {
  70.       if(this.bDoEntrySound)
  71.       {
  72.          if(Math.abs(TakGround.Instance.Coord.x - this.Coord.x) < Bird.nENTRY_SOUND_PLAYER_DIST)
  73.          {
  74.             this.bDoEntrySound = false;
  75.             var _loc2_ = Library.Utils.MoreMath.getRandomRange(1,100);
  76.             if(_loc2_ < 33)
  77.             {
  78.                Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdEntry-01.mp3",100,1,true);
  79.             }
  80.             else if(_loc2_ < 66)
  81.             {
  82.                Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdEntry-02.mp3",100,1,true);
  83.             }
  84.             else
  85.             {
  86.                Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"BirdEntry.mp3",100,1,true);
  87.             }
  88.          }
  89.       }
  90.       this.nSinGenerator += Bird.nSIN_INCREMENT;
  91.       var _loc3_ = Math.sin(this.nSinGenerator) * Bird.nSIN_MOD_MULT;
  92.       this.mcRef._x -= Bird.nMOVE_SPEED;
  93.       this.mcRef._y = this.nBaseY + _loc3_;
  94.    }
  95.    function doDie()
  96.    {
  97.       if(this.isStateComplete())
  98.       {
  99.          this.ParentLayer.doRemoveListener(this);
  100.          this.doDestroy();
  101.       }
  102.    }
  103. }
  104.